package com.cetcs.kmga.dataManager.global;

import com.cetcs.kmga.dataManager.util.ReadConfigUtil;

/**
 * 流向统计图片地址类
 *
 * @author xutao
 * @version V1_0 创建时间：2017-11-24 11:07
 *          Copyright 2017 by CETC
 */
public enum FlowStatImageUrlEnum {


    RESRC_TYPE_HBASE("HBase", "resrc.type.hbase"),
    RESRC_TYPE_MYSQL("MySQL", "resrc.type.mysql"),
    RESRC_TYPE_MONGO("Mongodb", "resrc.type.mongo"),
    RESRC_TYPE_SOLR("SOLR", "resrc.type.solr"),

    //资源图标
    RESRC_FLAG_HBASE("HBase_2", "resrc.flag.hbase"),
    RESRC_FLAG_MYSQL("MySQL_2", "resrc.flag.mysql"),
    RESRC_FLAG_MONGO("Mongodb_2", "resrc.flag.mongo"),
    RESRC_FLAG_SOLR("SOLR_2", "resrc.flag.solr"),

    //应用系统图标
    APP_FLAG_FG("FG", "app.flag.fg"),
    APP_FLAG_CJY("CJYJD", "app.flag.cjy"),
    APP_FLAG_FTP("FTP", "app.flag.ftp"),
    APP_FLAG_SYS("YYXT", "app.flag.sys"),
    APP_FLAG_HFZD("HFZD", "app.flag.hfzd"),
    APP_FLAG_UNKNOWN("WZZD", "app.flag.unknown"),
    APP_FLAG_DEL("QTHYSCJQ", "app.flag.del");

    private String typeName;

    private String flag;

    private final static String IMAGE_PRO_URL = "conf/flow-image.properties";

    private final static String IMAGE_PRO_ROOT_URL = ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, "url.root");

    public final static String IMAGE_PRO_LINE_SOURCE =IMAGE_PRO_ROOT_URL+ ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, "line.source");

    public final static String IMAGE_PRO_LINE_TARGET =IMAGE_PRO_ROOT_URL+ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, "line.target");

    public final static String IMAGE_PRO_SYS_DOWN =IMAGE_PRO_ROOT_URL+ ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, "image.pro.sys.down");


    public final static String IMAGE_FLOW_WARN=IMAGE_PRO_ROOT_URL+ ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, "flow.warn.url");


    FlowStatImageUrlEnum(String typeName, String flag) {
        this.typeName = typeName;
        this.flag = flag;
    }

    public static FlowStatImageUrlEnum getFlowStatImageUrlEnum(String name) {
        FlowStatImageUrlEnum typeRet = FlowStatImageUrlEnum.APP_FLAG_DEL;
        for (FlowStatImageUrlEnum type : FlowStatImageUrlEnum.values( )) {
            if (name.equals(type.getTypeName( ))) {
                typeRet = type;
                break;
            }
        }
        return typeRet;
    }

    public static String getImageUrl(String typeName) {
        String url = "";
        try {
            String currentFlag = getFlowStatImageUrlEnum(typeName).getFlag( );
            url = IMAGE_PRO_ROOT_URL + ReadConfigUtil.getValueByKey(IMAGE_PRO_URL, currentFlag);
        } catch (Exception ex) {
        }
        return url;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }
}
